# -*- coding: utf-8 -*-

from PyQt4.QtCore import QRect 
from PyQt4.QtGui import QDialog, QListWidget, QPushButton, QApplication
import os
import sys

class Dialog(QDialog):
    def __init__(self):
        QDialog.__init__(self)
        self.resize(300, 300)
        self.listWidget = QListWidget(self)
        self.listWidget.setGeometry(QRect(10, 20, 301, 231))
        self.pushButton = QPushButton(self)
        self.pushButton.setGeometry(QRect(20, 260, 97, 32))
        self.pushButton_2 = QPushButton(self)
        self.pushButton_2.setGeometry(QRect(200, 260, 97, 32))

        self.pushButton_2.clicked.connect(self.close)
        self.pushButton.clicked.connect(self.yaz)

        self.setWindowTitle(u"GNIS Disk Seçimi")
        self.pushButton.setText(u"Seç")
        self.pushButton_2.setText(u"İptal")

        devlist = os.listdir("/dev")
        sdlist = []
        for i in devlist:
            if i.startswith("sd") and len(i) >3:
                sdlist.append(i)

        sdlist.sort()
        self.listWidget.addItems(sdlist)
        #self.listWidget.

    def yaz(self):
	dosya = open("/tmp/gnis/disk.config","w")
        dosya.write(self.listWidget.item(self.listWidget.currentRow()).text())
        dosya.close()
        sys.exit()

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    Dialog = Dialog()
    Dialog.show()
    sys.exit(app.exec_())